package com.mva.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DB_Pipe
  {
   static private Connection DB_Pipe   = null;
   static private String     DB_Driver = "com.mysql.jdbc.Driver";
   static private String     DB_URL    = "jdbc:mysql://localhost:3306/m_v_a";
   static private String     DB_User   = "root";
   static private String     DB_Pswd   = "mysqlpswd";
   
   public static Connection DB_Connect ()
     {
	  try
	    {
   	     Class.forName(DB_Driver);
		 DB_Pipe = DriverManager.getConnection(DB_URL, DB_User, DB_Pswd);
	    }
	  catch(ClassNotFoundException e)
	    {
		 System.err.println("Database driver not found.");
	    }
	  catch(SQLException e)
	    {
		 System.err.println("Error connecting to the database: " + e);
	    }
	  return DB_Pipe; 
     }

   public static void DB_Disconnect (Connection con)
     {
	  try
	    {
		 con.close(); 
	    }
	  catch(SQLException e)
	    {
		 System.err.println("Error disconnecting from the database: " + e);
	    }
     }
  }
